#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)
#include <iostream>
using namespace std;
class _calculateday
{
public:
    _calculateday(int a, int b, int c)
    {
        _a = a;
        _b = b;
        _c = c;
    }
    int _day()
    {
        if ((_a % 4 == 0 && _a % 100 != 0) || _a % 400 == 0)
        {
            int i = 0;
            int d = 0;
            for (auto e : _arr)
            {
                i += e;
                ++d;
                if (_b == d)
                    break;
            }
            return _b > 2 ? i + _c + 1 : i + _c;
        }
        else
        {
            int i = 0;
            int d = 0;
            for (auto e : _arr)
            {
                i += e;
                ++d;
                if (_b == d)
                    break;
            }
            return i + _c;
        }
    }

private:
    int _a;
    int _b;
    int _c;
    int _arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
};

int main() {
    int a, b, c;
    while (cin >> a >> b >> c)
    {
        _calculateday d1(a, b, c);
        int _day = d1._day();
        cout << _day << endl;
    }
    return 0;
}